<template>
  <div>
    <div class="main" v-if="showFilter">
      <template v-for="item in HSList">
        <div class="item">
          <i class="label">{{ item.name }}: </i>
          <el-input
            v-if="item.type == 'input'"
            size="mini"
            class="Hinput"
            v-model="HSearchInfo[item.vm]"
            placeholder=""
          ></el-input>
          <div class="twoprice" v-else-if="item.type == 'twoinput'">
            <template v-for="ite in item.vm">
              <el-input
                class="priceType"
                size="mini"
                v-model="HSearchInfo[ite]"
                placeholder=""
              ></el-input>
            </template>
          </div>
          <div v-else-if="item.type == 'select'" class="selects">
            <select
              class="Hinput selectType"
              v-model="HSearchInfo[item.vm]"
              placeholder=""
            >
              <option
                class="option"
                v-for="ite in bookType"
                :key="ite.name"
                :label="ite.name"
                :value="ite.name"
              ></option>
            </select>
          </div>
        </div>
      </template>
      <div class="searchButton">
        <el-button size="mini" type="primary" class="">重置</el-button>
        <el-button size="mini" type="success" class="">筛选</el-button>
      </div>
    </div>
    <div class="openButton">
      <i
        @click="showFilter = showFilter ? false : true"
        :class="['text', showFilter ? 'totop' : 'tobottom']"
        >{{ showFilter ? "收起" : "展开" }}</i
      >
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showFilter: true,
      HSList: [
        {
          name: "关键字",
          type: "input",
          vm: "keyword",
        },
        {
          name: "书名",
          type: "input",
          vm: "bookName",
        },
        {
          name: "作者",
          type: "input",
          vm: "author",
        },
        {
          name: "出版社",
          type: "input",
          vm: "publisher",
        },
        {
          name: "店铺/发布者",
          type: "input",
          vm: " issuer",
        },
        {
          name: "分类",
          type: "select",
          vm: "bookType",
        },
        {
          name: "价格",
          type: "twoinput",
          vm: ["Hprice", "Lprice"],
        },
        {
          name: "折损",
          type: "input",
          vm: "depreciation",
        },
      ],
      HSearchInfo: {
        bookName: "",
        author: "",
        publisher: "",
        issuer: "",
        bookTypeName: "",
        Hprice: "",
        Lprice: "",
        depreciation: "",
        keyword: "",
      },
      bookType: [
        {
          name: "信息技术",
          url: "filter",
          code: "",
        },
        {
          name: "外国语",
          url: "",
          code: "",
        },
        {
          name: "农学",
          url: "",
          code: "",
        },
        {
          name: "动科",
          url: "",
          code: "",
        },
        {
          name: "理学",
          url: "",
          code: "",
        },
        {
          name: "教育学",
          url: "",
          code: "",
        },
        {
          name: "体育学",
          url: "",
          code: "",
        },
        {
          name: "经济与管理",
          url: "",
          code: "",
        },
        {
          name: "医学",
          url: "",
          code: "",
        },
        {
          name: "传媒",
          url: "",
          code: "",
        },
        {
          name: "材料",
          url: "",
          code: "",
        },
        {
          name: "其他",
          url: "",
          code: "",
        },
      ],
    };
  },
  props: ["pHSList", "pHSearchInfo"],
  created() {},
  mounted() {
    this.HSList =
      this.pHSList == null || this.pHSList == "" ? this.HSList : this.pHSList;
    this.HSearchInfo =
      this.pHSearchInfo == null || this.pHSearchInfo == ""
        ? this.HSearchInfo
        : this.pHSearchInfo;
    // console.log("leftTypeList => leftNav", this.leftNav == this.navList);
  },
};
</script>

<style lang="less" scoped>
.main {
  // background: #000;
  padding-bottom: 40px;
  position: relative;
  display: flex;
  flex-flow: row wrap;
  font-size: 12px;
  color: lightslategrey;
  .item {
    display: flex;
    flex-flow: row wrap;
    position: relative;
    margin: 10px 14px;
    .label {
      padding-top: 12px;
      margin-right: 10px;
    }
    .el-input {
      width: 100px;
      height: 20px;
    }
    .Hinput {
      width: 100px;
      height: 20px;
    }
    .selects {
      .selectType {
        width: 100px;
      }
    }
    .twoprice {
      display: inline;
      .el-input {
        width: 60px;
      }
      .el-input:first-child {
        margin-right: 30px;
        position: relative;
      }
      .el-input:first-child::after {
        position: absolute;
        content: "—";
        font-weight: 700;
        transform: translateX(8px);
        margin-top: 4px;
      }
    }
    .selects {
      display: inline;
      .selectType {
        line-height: 2;
        height: 30px;
        outline: none;
        border-color: lightgrey;
      }
    }
  }
  .searchButton {
    position: absolute;
    right: 10px;
    bottom: 0;
    vertical-align: bottom;
  }
}
.openButton {
  border-top: 1px solid lightslategray;
  text-align: center;
  .text {
    position: relative;
    color: rgb(105, 105, 233);
    background: linear-gradient(white, rgb(193, 197, 202));
    padding: 7px 30px 4px 10px;
    line-height: 2;
    border: 1px solid lightslategray;
    border-top: none;
  }
  .text:hover {
    cursor: pointer;
  }
  .text::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    border-top: 2px solid rgb(105, 105, 233);
    border-right: 2px solid rgb(105, 105, 233);
    top: 14px;
    right: 10px;
  }
  .totop::after {
    transform: rotate(-45deg);
  }
  .tobottom::after {
    transform: rotate(135deg);
  }
}
</style>